
<?php

/*
 * Read file danhmuc.xml, put a group of danh muc to select tag, decorate select tag by Kendo Combobox
 * Consider to add Placeholder and width attribute
 * ***Usage***
 * <?php echo $this->partial("danhmuc_select_tag.php"
                         , array("name"=>"object_code", "id"=>"cboMessageType", "cbo_name"=>"message"
,"selected"=>"MARK", "hasAll"=>true)) ?>
 */

use Core\Config;
use Core\Constant;

$danhMucConfig = Config::getDanhMucConfig();
$name = $this->name;
$objectCodes = $danhMucConfig->$name;
$hasAll = $this->hasAll;
?>
<?php
    echo '<select id="'.$this->id.'" name="'.$this->cbo_name.'" >';
    $selected="";
    if($hasAll)echo '<option value="'.Constant::$SELECT_ALL_VALUE.'"  >'."{lang:All}".'</option>';
    foreach ($objectCodes as $key => $val) {
        $selectedVal = $this->selected;
        if($key == $selectedVal)
            $selected = "selected";
        else
            $selected = "";
        echo '<option value="'.$key.'" '.$selected.' >'.$val.'</option>';
    }
    ?>
</select>

